package assist.client.gwt.view.activity;

import com.google.web.bindery.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

import assist.client.gwt.view.ClientFactory;
import assist.client.gwt.view.place.SelectStatsPlace;
import assist.client.gwt.view.place.ShowStatsPlace;
import assist.client.gwt.view.ui.ShowStatsView;

public class ShowStatsActivity extends StatsActivity 
    implements ShowStatsView.Presenter
{

	public ShowStatsActivity(ShowStatsPlace place, ClientFactory clientFactory)
	{
	    super(place, clientFactory, clientFactory.getShowStatsView());
		this.statsProvider.fetchStats();
	}

	@Override
	public void start(AcceptsOneWidget containerWidget, EventBus eventBus) {
	    
	    ShowStatsView showStatsView = clientFactory.getShowStatsView();	    
	    showStatsView.setPresenter(this);
		containerWidget.setWidget(showStatsView.asWidget());
        //TODO: Logic here or in provider so stats not fetched if already fetched. 
        //TODO: Should this be done in start?  kicks off the async query.         
	}

    @Override
    public void goToSelectStats() 
    {
        clientFactory.getPlaceController().goTo(new SelectStatsPlace(
                this.clientFactory.getGamesProvider().getGamesQuery(), 
                this.statsProvider.getStatsQuery()));
    }

}